import { request } from "../request";

const Api = {
    register: '/web/rider/register-rider',
    getRiderId: '/web/rider/findr-rider/id=',
    update: '/web/rider/update',
    notOrder: '/web/order-grabbing/received?',
    connect: '/web/order-grabbing/rider-connect',
    over: '/web/order-grabbing/order-over',
    del: '/web/order-grabbing/del/id=',
    evaluate: '/web/rider/evaluate',
    evaId: '/web/rider/evaluate/id='
} 

/**
 * 注册接口
 * @param formData array 提交用户信息参数
 * @return {AxiosPromise}
 */
export function riderRegister(formData) {
    return request({
        url: Api.register,
        method: 'post',
        data: formData
    })
}

/**
 * 更新骑手信息接口
 * @param formData array 提交用户信息参数
 * @return {AxiosPromise}
 */
export function updateRider(formData) {
    return request({
        url: Api.update,
        method: 'post',
        data: formData
    })
}

/**
 * 根据id查询骑手信息
 * @param id Integer 提交用户id
 * @return {AxiosPromise}
 */
export function getRiderById(userId){
    return request({
        url: Api.getRiderId + userId,
        method: 'GET'
    })
}

/**
 * 未接订单
 * @return {AxiosPromise}
 */
export function getNotOrder(param){
    return request({
        url: Api.notOrder,
        method: 'GET',
        params: param
    })
}

/**
 * 骑手抢单
 * @return {AxiosPromise}
 */
export function riderConnectOrder(param){
    return request({
        url: Api.connect,
        method: 'POST',
        data: param
    })
}

/**
 * 点击送达
 * @return {AxiosPromise}
 */
export function riderOverOrder(param){
    return request({
        url: Api.over,
        method: 'POST',
        data: param
    })
}

/**
 * 删除订单
 * @return {AxiosPromise}
 */
export function delOrderGrabbing(id){
    return request({
        url: Api.del + id,
        method: 'GET'
    })
}

/**
 * 骑手评价
 * @param formData array 提交用户信息参数
 * @return {AxiosPromise}
 */
export function riderEvaluate(formData) {
    return request({
        url: Api.evaluate,
        method: 'post',
        data: formData
    })
}

/**
 * 查看骑手评价
 * @return {AxiosPromise}
 */
export function riderEvaluateById(id) {
    return request({
        url: Api.evaId + id,
        method: 'GET'
    })
}
